home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1934 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: feenix.metronet.com!news
  2. From: Gavin Williams <gavin@metronet.com>
  3. Newsgroups: comp.os.ms-windows.programmer.win32,comp.lang.c++
  4. Subject: Sockets don't work under VC++ 4.0 ?!!
  5. Date: Sun, 14 Jan 1996 00:54:49 -0600
  6. Organization: Texas Metronet, Inc  (login info (214/705-2901 - 817/571-0400))
  7. Message-ID: <30F8A8B9.279B@metronet.com>
  8. NNTP-Posting-Host: dal150.metronet.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0b3 (WinNT; I)
  13.  
  14. I finally got around to doing a little Windows Sockets programming in VC++ 
  15. 4.0 today and was quickly greeted with an ugly problem--I can't get it to 
  16. create a socket.
  17.  
  18. The CSocket::Create() function consistently failed, and 
  19. CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the CHATTER 
  20. sample program, and its socket creation failed with the same error.
  21.  
  22. Then I tried tried straight socket API calls (as opposed to using the CSocket 
  23. or CAsyncSocket classes). The "socket" function also failed with the 
  24. WSAEPROTOTYPE error.
  25.  
  26. Finally, I tried some simple sockets code in VC++ 1.52c and VC++ 2.2. The 
  27. code *worked* in both cases. The *exact same code* works fine when compiled 
  28. with 2.2 but fails when compiled with 4.0.
  29.  
  30. Here's a sample of my test code:
  31.  
  32.   WSADATA wsadata;
  33.   WSAStartup( 0x0101, &wsadata );
  34.  
  35.   SOCKET sock;
  36.   if( INVALID_SOCKET == (sock = socket( PF_INET, SOCK_STREAM, 0 )) )
  37.     {
  38.     int i = WSAGetLastError();
  39.     }
  40.  
  41.   WSACleanup();
  42.  
  43. Two other tidbits:  I'm running NT 3.51, and Microsoft's knowledge base 
  44. contained nothing about this problem.
  45.  
  46. Has anyone else out there encountered this problem?  Is anyone using sockets 
  47. successfully with VC++ 4.0?
  48.  
  49. Gavin Williams
  50. gavin@metronet.com
  51.